package app.kafka.consume;

import java.util.Optional;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

//@Component
public class KafkaConsumerTest {
	private static Logger logger = LoggerFactory.getLogger(KafkaConsumerTest.class);
	
	/**
	 * 监听主题 system_info_topic ，获取系统信息
	 * @author lfy.xys
	 * @date 2018年5月3日
	 *
	 * @param record
	 */
//	@KafkaListener(topics = {"system_info_topic"},groupId = "${kafka.consume.group.id}")
    public void listen(ConsumerRecord<?, ?> record) {

        Optional<?> kafkaMessage = Optional.ofNullable(record.value());
        if (kafkaMessage.isPresent()) {
            Object message = kafkaMessage.get();

            logger.info("--------------- record =" + record);
            logger.info("-------------------- message =" + message);
        }

    }
}
